//首页banner登陆框
$(document).ready($(function(){
    gaintop = $(".banner .pf").css("top");
        $(".banner .pf").css("top", -695);
//      $("#banpic .gain").animate({
//          top: gaintop,
//          opacity: 1
//      }, 800);
        $(".banner .pf").animate({
            top: gaintop+102
        }, 500);
        $(".banner .pf").animate({
            top: gaintop
        }, 200);
        $(".banner .pf").animate({
            top: '-=12px'
        }, 200);
        $(".banner .pf").animate({
            top: gaintop
        }, 200);
        $(".banner .pf").animate({
            top: '-=3px'
        }, 100);

$(".banner .pf").animate({

    top: '+=1px'

}, 100);
        $(".banner .pf").animate({
            top: gaintop
        }, 100);
}));

//////////////////////////计数器
$(document).ready(function(){
    $.fn.countTo = function(options) {
    options = options || {};
    return $(this).each(function() {
        var settings = $.extend({}, $.fn.countTo.defaults, {
            from: $(this).data("from"),
            to: $(this).data("to"),
            speed: $(this).data("speed"),
            refreshInterval: $(this).data("refresh-interval"),
            decimals: $(this).data("decimals")
        }, options);
        var loops = Math.ceil(settings.speed / settings.refreshInterval),
            increment = (settings.to - settings.from) / loops;
        var self = this,
            $self = $(this),
            loopCount = 0,
            value = settings.from,
            data = $self.data("countTo") || {};
        $self.data("countTo", data);
        if (data.interval) {
            clearInterval(data.interval)
        }
        data.interval = setInterval(updateTimer, settings.refreshInterval);
        render(value);

        function updateTimer() {
            value += increment;
            loopCount++;
            render(value);
            if (typeof(settings.onUpdate) == "function") {
                settings.onUpdate.call(self, value)
            }
            if (loopCount >= loops) {
                $self.removeData("countTo");
                clearInterval(data.interval);
                value = settings.to;
                if (typeof(settings.onComplete) == "function") {
                    settings.onComplete.call(self, value)
                }
            }
        }
        function render(value) {
            var formattedValue = settings.formatter.call(self, value, settings);
            $self.html(formattedValue)
        }
    })
};
$.fn.countTo.defaults = {
    from: 0,
    to: 0,
    speed: 1000,
    refreshInterval: 100,
    decimals: 0,
    formatter: formatter,
    onUpdate: null,
    onComplete: null
};

function formatter(value, settings) {
    return value.toFixed(settings.decimals)
}
$("#count-number,#count-number2").data("countToOptions", {
    formatter: function(value, options) {
        return value.toFixed(options.decimals).replace(/\B(?=(?:\d{3})+(?!\d))/g, ",")
    }
});
$(".timer").each(count);

function count(options) {
    var $this = $(this);
    options = $.extend({}, options || {}, $this.data("countToOptions") || {});
    $this.countTo(options)
};
});

//banner轮播
$(document).ready(function(){

	$(".main_visual").hover(function(){
		$("#btn_prev,#btn_next").fadeIn()
	},function(){
		$("#btn_prev,#btn_next").fadeOut()
	});
	
	$dragBln = false;
	
	$(".main_image").touchSlider({
		flexible : true,
		speed : 200,
		btn_prev : $("#btn_prev"),
		btn_next : $("#btn_next"),
		paging : $(".flicking_con a"),
		counter : function (e){
			$(".flicking_con a").removeClass("on").eq(e.current-1).addClass("on");
		}
	});
	
	$(".main_image").bind("mousedown", function() {
		$dragBln = false;
	});
	
	$(".main_image").bind("dragstart", function() {
		$dragBln = true;
	});
	
	$(".main_image a").click(function(){
		if($dragBln) {
			return false;
		}
	});
	
	timer = setInterval(function(){
		$("#btn_next").click();
	}, 5000);
	
	$(".main_visual").hover(function(){
		clearInterval(timer);
	},function(){
		timer = setInterval(function(){
			$("#btn_next").click();
		},5000);
	});
	
	$(".main_image").bind("touchstart",function(){
		clearInterval(timer);
	}).bind("touchend", function(){
		timer = setInterval(function(){
			$("#btn_next").click();
		}, 5000);
	});
	
});

//进度条
// $(document).ready(function(){
//     var b = {
//             top: $(window).scrollTop(),
//             bottom: $(window).scrollTop() + $(window).height()
//         };
//     $(".jdt").each(function(){
//         if( b.top <= $(this).offset().top && b.bottom >= $(this).offset().top){
//                 var h = $(this).children("i").text();
//                 $(this).children("span").stop().animate({ width : h} , 1500);
//                 var w = $(this).children("span").css("width")
//            }
//     })
// });
// $(window).scroll(function(){
//     var b = {
//             top: $(window).scrollTop(),
//             bottom: $(window).scrollTop() + $(window).height()
//         };
//     $(".jdt").each(function(){
//         if( b.top <= $(this).offset().top && b.bottom >= $(this).offset().top){
//                 var h = $(this).children("i").text();
//                 $(this).children("span").stop().animate({ width : h} , 1500);
//                 var w = $(this).children("span").css("width")
//            }
//     })
// });
$(window).scroll(function(){
    dongh();
})
$(document).ready(function(){
    dongh();
})
function dongh(){
    var b = {
            top: $(window).scrollTop(),
            bottom: $(window).scrollTop() + $(window).height()
        };
    $(".jdt").each(function(){
        if( b.top <= $(this).offset().top && b.bottom >= $(this).offset().top){
                var h = $(this).children("i").text();
                $(this).children("span").stop().animate({ width : h} , 1500);
                var w = $(this).children("span").css("width")
           }
    })
}